import pyglet,sys,os,math,time
from pyglet.gl import *
from framework import *
from widget import *

import Image
import ImageOps

class modeEdit:
    """ Edit Mode """

    def __init__(self):
        return

    def applyAndSave(self, loadImageName, saveImageName, degrees, flipH, flipV):
        if flipH and flipV:
            flipH = False
            flipV = False
            degrees += 180
        try:
            pic = Image.open(loadImageName)
            if flipH:
                pic = ImageOps.mirror(pic)
            elif flipV:
                pic = ImageOps.flip(pic)
            else:
                pic = pic.rotate(degrees)

            pic.save(saveImageName)
        except IOError:
            print "Unable to modify", saveImageName
        

if __name__ == "__main__":
    main = modeEdit()
    main.applyAndSave("Sun.jpg", "Sun.jpg", 180, False, False)
    pyglet.app.run()
